package com.ymatou.query.trading.api.testcase;

import java.util.ArrayList;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetSellerOrdersListV2Bean;
import com.ymatou.query.trading.api.service.GetSellerOrdersListV2Call;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.common.enums.DateTypeEnum;
import com.ymttest.common.enums.OrderStatusEnum;
import com.ymttest.utils.constant.ECode;

/**
 * 获取商家订单列表V2 FreeMaker Template自动生成代码
 * 
 * @param <GetSellerOrdersListV2Bean>
 */
@TestSuite
public class Ts_GetSellerOrdersListV2 {

	private static GetSellerOrdersListV2Bean getsellerorderslistv2bean;
	private static GetSellerOrdersListV2Call getsellerorderslistv2call;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商家订单列表V2");
	}

	@Before
	public void caseUp() {

		getsellerorderslistv2bean = new GetSellerOrdersListV2Bean();
		getsellerorderslistv2call = new GetSellerOrdersListV2Call();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getsellerorderslistv2call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetSellerOrdersListV2_001() {
		Logger.start(true,"获取商家订单列表V2成功");
		try {
			// 参数
			ArrayList<DateTypeEnum> DateList = new ArrayList<DateTypeEnum>();
			DateList.add(DateTypeEnum.All);
			getsellerorderslistv2bean.setDateList(DateList);
			getsellerorderslistv2bean.setLastOrderId(500384776);
			getsellerorderslistv2bean.setOrderNum(10);
			ArrayList<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.SellerAccept.getValue());
			getsellerorderslistv2bean.setOrderStatusList(OrderStatusList);
			int SellerId = 288484;
			getsellerorderslistv2bean.setSellerUserId(SellerId);
			// 发送请求
			getsellerorderslistv2call.setData(getsellerorderslistv2bean);
			getsellerorderslistv2call.callService();
			Logger.comment("getsellerorderslistv2call send:" + getsellerorderslistv2call.getEntityString());
			Logger.comment("getsellerorderslistv2call response:" + getsellerorderslistv2call.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getsellerorderslistv2call.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getsellerorderslistv2call.getMsg(), "验证Msg");
			Logger.verifyEquals(10, getsellerorderslistv2call.getOrderInfoList().length(), "验证查询结果长度");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetSellerOrdersListV2_002() {
		Logger.start(true,"卖家用户id为空");
		try {
			// 参数
			ArrayList<DateTypeEnum> DateList = new ArrayList<DateTypeEnum>();
			DateList.add(DateTypeEnum.All);
			getsellerorderslistv2bean.setDateList(DateList);
			getsellerorderslistv2bean.setLastOrderId(500384776);
			getsellerorderslistv2bean.setOrderNum(10);
			ArrayList<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.SellerAccept.getValue());
			getsellerorderslistv2bean.setOrderStatusList(OrderStatusList);
			int SellerId = 288484;
			// getsellerorderslistv2bean.setSellerUserId(SellerId);
			// 发送请求
			getsellerorderslistv2call.setData(getsellerorderslistv2bean);
			getsellerorderslistv2call.callService();
			Logger.comment("getsellerorderslistv2call send:" + getsellerorderslistv2call.getEntityString());
			Logger.comment("getsellerorderslistv2call response:" + getsellerorderslistv2call.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, getsellerorderslistv2call.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getsellerorderslistv2call.getMsg(), "验证Msg");
			// Logger.verifyEquals(10,getsellerorderslistv2call.getOrderInfoList().length(),"验证查询结果长度");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetSellerOrdersListV2_003() {
		Logger.start(true,"卖家用户id不存在");
		try {
			// 参数
			ArrayList<DateTypeEnum> DateList = new ArrayList<DateTypeEnum>();
			DateList.add(DateTypeEnum.All);
			getsellerorderslistv2bean.setDateList(DateList);
			getsellerorderslistv2bean.setLastOrderId(500384776);
			getsellerorderslistv2bean.setOrderNum(10);
			ArrayList<Integer> OrderStatusList = new ArrayList<Integer>();
			OrderStatusList.add(OrderStatusEnum.SellerAccept.getValue());
			getsellerorderslistv2bean.setOrderStatusList(OrderStatusList);
			int SellerId = 1;
			getsellerorderslistv2bean.setSellerUserId(SellerId);
			// 发送请求
			getsellerorderslistv2call.setData(getsellerorderslistv2bean);
			getsellerorderslistv2call.callService();
			Logger.comment("getsellerorderslistv2call send:" + getsellerorderslistv2call.getEntityString());
			Logger.comment("getsellerorderslistv2call response:" + getsellerorderslistv2call.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getsellerorderslistv2call.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getsellerorderslistv2call.getMsg(), "验证Msg");
			Logger.verifyEquals(0, getsellerorderslistv2call.getOrderInfoList().length(), "验证查询结果长度");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}